package com.example.springdemo.reg;

import com.example.springdemo.log.TimeConsume;
import dk.brics.automaton.Automaton;
import dk.brics.automaton.RegExp;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * TODO
 *
 * @author pengzhikang
 * @date 2021/11/29 10:57
 * @since 1.0.0
 */
@Service
@Slf4j
public class RegService {

    @TimeConsume
    public void reg(String reg, String text) {
        RegExp regExp = new RegExp(reg);
        Automaton automaton = regExp.toAutomaton();
        log.info(automaton.toString());
        log.info("Match:{}", automaton.run(text));
    }
}
